package com.ysyx.ysyx_census.controller;

import com.ysyx.ysyx_census.dto.BaseDto;
import com.ysyx.ysyx_census.dto.CensusDto;
import com.ysyx.ysyx_census.mapper.OrderPojoMapper;
import com.ysyx.ysyx_census.mapper.OrderdetailPojoMapper;
import com.ysyx.ysyx_census.service.OrderPojoService;
import com.ysyx.ysyx_census.service.OrderdetailPojoService;
import org.redisson.api.RKeys;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: xxxx接口/类
 * @author:郭宇轩
 * @create:2023/4/21 11:02
 */
@RestController
@RequestMapping("/census")
public class CensusController {

    @Autowired
    private OrderPojoService orderPojoService;

    @Autowired
    private OrderdetailPojoService orderdetailPojoS;
    @Autowired
    private RedissonClient redissonClient;


    @RequestMapping(value = "/driver/wages",method = RequestMethod.GET)
    public BaseDto driverWages(Integer driverId){
        BaseDto baseDto = orderPojoService.driverWages(driverId);
        return baseDto;
    }

    @RequestMapping(value = "/allresult",method = RequestMethod.GET)
    public CensusDto census(){
        CensusDto censusDto = new CensusDto();
        censusDto.setMonthIncomeList(orderPojoService.sixMonthIncomingCalc());
        censusDto.setMonthOrderNumList(orderPojoService.sixMonthOrderCalc());
        censusDto.setMonthReviewRateList(orderPojoService.monthPassengerReviewRate());
        censusDto.setNowWorkingDriverNum(orderPojoService.workingDriver());
        censusDto.setMonthRegisterPassengerNum(orderPojoService.monthRegisterPassengerNum());
        return censusDto;
    }

    @RequestMapping(value="/redisArea",method = RequestMethod.GET)
    public BaseDto keys(){
        RMap<Object, Object> map = redissonClient.getMap("area:Fuzhou");
        for (Map.Entry<Object,Object> o:
             map.entrySet()) {
            System.out.println("k="+o.getKey()+",v="+o.getValue());
        }

        return new BaseDto(0,map.toString(),null);

    }

    @RequestMapping("/getOrderStartPoint")
    public BaseDto getSeaMap(){




        return orderdetailPojoS.getOrderList();
    }


}
